var kafka = require('kafka-node'),
  Producer = kafka.Producer,
  KeyedMessage = kafka.KeyedMessage,
  client = new kafka.Client('112.74.93.133:2181'),
  producer = new Producer(client),
  km = new KeyedMessage('key', 'message'),
  payloads = [
    {
      topic: 'helloworld5',
      messages: 'hi',
      partition: 0
    },
    {
      topic: 'helloworld5',
      messages: ['hello', 'world'],
      partition: 1
    },
    {
      topic: 'helloworld5',
      messages: ['hello', 'world'],
      partition: 2
    },
    {
      topic: 'helloworld5',
      messages: ['hello', 'world'],
      partition: 3
    },
  ];
producer.on('ready', function() {
  let index = 1;
  while (index < 10000) {
    producer.send(payloads, function(err, data) {
      console.info(err)
      console.log(data);
    });
    index++;
  }
  console.info('done')
});

producer.on('error', function(err) {})